<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闭包定时器</title>
</head>
<body>
    <script>
        function doSth(){
            console.log("执行")
        }
        let switcher = false
        function mySetInterVal(fn,a,b){
            var i = 0
            while(!switcher){

                setInterval(fn,a+i*b)
                i++

            }
            return
            
        }

            function myClear(){
                switcher=true
            }
        var myClear = mySetInterVal(doSth,1000,500)
    </script>
</body>
</html>